<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NeoAI - 设置</title>
    <link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='NeoAI.ico') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='config.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='menu.css') }}">
</head>

<body>

    <script src="{{ url_for('static', filename='menu.js') }}"></script>
    <div class="header" onclick="showMenu()">NeoAI - 设置</div>
    <div id="menuOverlay" class="hidden"></div>
    <div style="min-height: 400px;"></div>
    
    <div class="container">
        <form id="config_form">
            <button type="button" id="toggle_password" onclick="togglePasswordVisibility()">查看隐私项👁️</button>
            <label for="api_key">
                API Key:
                <span class="tooltip-icon" data-tooltip="请输入您的 OpenAI API 密钥">?</span>
            </label>
            <input type="password" id="api_key" name="API_KEY" value="{{ config['API_KEY'] }}">
            
            
            <label for="api_base_url">
                API Base URL:
                <span class="tooltip-icon" data-tooltip="请输入您的 API 基础 URL，默认值为 https://api.openai.com/v1/chat/completions">?</span>
            </label>
            <input type="text" id="api_base_url" name="API_BASE_URL" value="{{ config['API_BASE_URL'] }}">
            
            <label for="model">
                模型:
                <span class="tooltip-icon" data-tooltip="请输入您希望使用的模型名称，例如 gpt-4">?</span>
            </label>
            
            <input type="text" id="model" name="MODEL" value="{{ config['MODEL'] }}">



            <label for="execution_level">
                安全等级:
                <span class="tooltip-icon" data-tooltip="输入安全等级，范围 0 - 3。">?</span>
            </label>

            <input type="number" id="execution_level" name="EXECUTION_LEVEL" min="0" max="3" value="{{ config['EXECUTION_LEVEL'] }}">

            <label for="return_timeout">
                执行超时:
                <span class="tooltip-icon" data-tooltip="输入超时时间(单位秒)，-1为自适应超时时间。">?</span>
            </label>

            <input type="number" id="return_timeout" name="RETURN_TIMEOUT" step="0.1" value="{{ config['RETURN_TIMEOUT'] }}">

            <label for="temperature">
                温度:
                <span class="tooltip-icon" data-tooltip="设置温度，范围 0 - 2。">?</span>
            </label>

            <input type="number" id="temperature" name="TEMPERATURE" step="0.05" min="0" max="2" value="{{ config['TEMPERATURE'] }}">

            <label for="max_tokens">
                最大Token数:
                <span class="tooltip-icon" data-tooltip="设置输出最大Token数。">?</span>
            </label>

            <input type="number" id="max_tokens" name="MAX_TOKENS" step=""  value="{{ config['MAX_TOKENS'] }}">

            <label for="max_turns">
                最大对话保存轮数:
                <span class="tooltip-icon" data-tooltip="设置最大对话保存轮数，1 轮 = 2 条对话(用户提问 + AI回答)">?</span>
            </label>

            <input type="number" id="max_turns" name="MAX_TURNS" step=""  value="{{ config['MAX_TURNS'] }}">


            <button type="button" id="update_button" onclick="saveConfig()">保存配置</button>
        </form>
    </div>

    <script src="{{ url_for('static', filename='config.js') }}"></script>
    <script src="{{ url_for('static', filename='scripts.js') }}"></script>

</body>

</html>
